home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_olv_jag_temple.cog < prev    next >
Text File  |  1999-11-15  |  9KB  |  467 lines

  1. # Jones 3D Cog Script
  2. #
  3. # olv_jag_temple.cog   
  4. #
  5. # [SCHOLL]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10. symbols
  11.  
  12. message entered
  13. message    startup
  14. message    aievent
  15. message    arrivedwpnt
  16. message timer
  17. message user0
  18.  
  19. thing    t_Jag
  20. thing    t_Indy        local
  21.  
  22. int        b_Operational=1    local
  23. int        n_eventType        local
  24. int        n_CrntAIMode     local
  25. int        n_OldAIMode     local
  26. int        n_Waypoint        local
  27. int        n_Temp            local
  28. int        b_Temp            local
  29. flex    f_Temp            local
  30. int        n_TimerID        local 
  31. int        n_idx            local
  32. int        b_WpntsActive=0    local
  33. int        n_IndyWaypoint    local
  34. int        n_FleeToWaypoint local
  35.  
  36. vector    v_IndyPos        local
  37. vector    v_JagPos        local
  38. vector    v_JagToIndy        local
  39. vector    v_IndyLook        local
  40. vector    v_Temp            local
  41.  
  42.  
  43.  
  44. # ===========================FLEE WAYPOINTS================================================
  45. int            NUM_FLEE_WAYPOINTS=11            local
  46. thing        t_Waypoint00
  47. thing        t_Waypoint01
  48. thing        t_Waypoint02
  49. thing        t_Waypoint03
  50. thing        t_Waypoint04
  51. thing        t_Waypoint05
  52. thing        t_Waypoint06
  53. thing        t_Waypoint07
  54. thing        t_Waypoint08
  55. thing        t_Waypoint09
  56. thing        t_Waypoint10
  57.  
  58.  
  59. # ===========================SECTORS================================================
  60.  
  61. int            NUM_AUTO_FLEE_SECTORS=2     local
  62. sector        s_AutoFlee00            mask=0x5 # need entered messages from jag
  63. sector        s_AutoFlee01            mask=0x5 # need entered messages from jag
  64.  
  65. int            NUM_ACTIVATE_WPNT_SECTORS=2 local
  66. sector        s_ActivateWpnts00
  67. sector        s_ActivateWpnts01
  68.  
  69. int            NUM_DEACTIVATE_WPNT_SECTORS=2 local
  70. sector        s_DeactivateWpnts00
  71. sector        s_DeactivateWpnts01
  72.  
  73.  
  74. # ===========================MISC CONSTANTS================================================
  75.  
  76.  
  77.  
  78.     flex        activatewaypoints            local
  79.     flex        deactivatewaypoints        local
  80.     flex        choosefleewaypoint        local
  81.     flex        resetwaypointranks        local
  82.     int        f_disttoindy            local
  83.     flex        rankfor9                local
  84.     flex        rankfor10                local
  85.     flex        rankfor8                local
  86.     flex        rankfor2                local
  87.     flex        rankfor1                local
  88.     flex        rankfor0                local
  89.  
  90.  
  91.  
  92. end
  93. # ========================================================================================
  94.  
  95. code
  96. startup:
  97.     t_Indy=GetLocalPlayerThing();
  98.  
  99.     return;
  100.  
  101. # ========================================================================================
  102. entered:
  103.     if (!b_Operational)
  104.     {
  105.         return;
  106.     }
  107.  
  108.     if (GetSourceRef() == t_Indy)
  109.     {
  110.         for (n_idx = 0; n_idx < NUM_ACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  111.         {
  112.             if (GetSenderRef() == s_ActivateWpnts00[n_idx])
  113.             {
  114.                 call ActivateWaypoints;
  115.             }
  116.         }
  117.         for (n_idx = 0; n_idx < NUM_DEACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  118.         {
  119.             if (GetSenderRef() == s_DeactivateWpnts00[n_idx])
  120.             {
  121.                 call DeactivateWaypoints;
  122.             }
  123.         }
  124.     }
  125.     else if (GetSourceRef() == t_Jag)
  126.     {
  127.         for (n_idx = 0; n_idx < NUM_AUTO_FLEE_SECTORS; n_idx = n_idx + 1)
  128.         {
  129.             if (GetSenderRef() == s_AutoFlee00[n_idx])
  130.             {
  131.                 AIFlee(t_Jag, t_Indy);
  132.             }
  133.         }
  134.     }
  135.  
  136.     return;
  137.  
  138. # ========================================================================================
  139. aievent:
  140.     if (!b_Operational)
  141.     {
  142.         return;
  143.     }
  144.  
  145.     n_eventType        = GetParam(0);
  146.     n_CrntAIMode    = GetParam(1);
  147.     n_OldAIMode        = GetParam(2);    // only valid for certain n_eventType values
  148.  
  149.     if (n_eventType == 0x100)        // SITHAI_EVENTMODECHANGED
  150.     {
  151.         // if changing to flee mode
  152.         // turn on waypoints
  153.         if ( !BITTEST(n_OldAIMode, 0x800) && BITTEST(n_CrntAIMode, 0x800) )
  154.         {
  155.             AISetSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  156.             call ChooseFleeWaypoint;
  157.         }
  158.         // if exiting flee mode
  159.         // turn off waypoints
  160.         else if ( BITTEST(n_OldAIMode, 0x800) && !BITTEST(n_CrntAIMode, 0x800) )
  161.         {
  162.             AIClearSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  163.             call ResetWaypointRanks;
  164.         }
  165.     }
  166.  
  167. return;
  168.  
  169. # ========================================================================================
  170. timer:
  171.     if (!b_Operational)
  172.     {
  173.         return;
  174.     }
  175.  
  176.     t_Indy = GetLocalPlayerThing();
  177.  
  178.     n_TimerID = GetSenderID();
  179.  
  180.     return;
  181.  
  182.  
  183. # ========================================================================================
  184. arrivedwpnt:
  185.     if (!b_Operational)
  186.     {
  187.         return;
  188.     }
  189.  
  190.     n_Waypoint = GetParam(0);
  191.  
  192.     if ( BITTEST(AIGetMode(t_Jag), 0x800))
  193.     {
  194.         call ChooseFleeWaypoint;
  195.  
  196.         if (n_Waypoint == n_FleeToWaypoint)
  197.         {
  198.             StopThing(t_Jag);
  199.             AIStopFlee(t_Jag);
  200.         }
  201.     }
  202.     
  203.     return;
  204.  
  205. # ========================================================================================
  206. user0:
  207.     b_Operational = 0;
  208.     SetThingFlags(t_Jag, 0x80000);
  209.     AISetMode(t_Jag, 0x2000);
  210.     return;
  211.  
  212. # ========================================================================================
  213. ChooseFleeWaypoint:
  214.     v_IndyPos = GetThingPos(t_Indy);
  215.     v_JagPos = GetThingPos(t_Jag);
  216.  
  217.     // If Indy is on second level then always go behind statue
  218.     if ((VectorZ(v_IndyPos) - VectorZ(v_JagPos)) > 0.2)
  219.     {
  220.         call RankFor9;
  221.         return;
  222.     }
  223.  
  224.     n_IndyWaypoint = AIFindNearestWpnt(t_Indy);
  225.  
  226.     if (n_IndyWaypoint == 0)
  227.     {
  228.         call RankFor9;
  229.     }
  230.     else if (n_IndyWaypoint == 1)
  231.     {
  232.         call RankFor9;
  233.     }
  234.     else if (n_IndyWaypoint == 2)
  235.     {
  236.         call RankFor9;
  237.     }
  238.     else if (n_IndyWaypoint == 3)
  239.     {
  240.         call RankFor10;
  241.     }
  242.     else if (n_IndyWaypoint == 4)
  243.     {
  244.         call RankFor9;
  245.     }
  246.     else if (n_IndyWaypoint == 5)
  247.     {
  248.         call RankFor9;
  249.     }
  250.     else if (n_IndyWaypoint == 6)
  251.     {
  252.         call RankFor10;
  253.     }
  254.     else if (n_IndyWaypoint == 7)
  255.     {
  256.         call RankFor8;
  257.     }
  258.     else if (n_IndyWaypoint == 8)
  259.     {
  260.         call RankFor2;
  261.     }
  262.     else if (n_IndyWaypoint == 9)
  263.     {
  264.         call RankFor1;
  265.     }
  266.     else if (n_IndyWaypoint == 10)
  267.     {
  268.         call RankFor1;
  269.     }
  270.  
  271.     return;
  272.  
  273. # ========================================================================================
  274. ActivateWaypoints:
  275.     if (b_WpntsActive)
  276.     {
  277.         return;
  278.     }
  279.  
  280.     b_WpntsActive = 1;
  281.     AISetInstinctWpntMode(t_Jag);
  282.  
  283.     for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
  284.     {
  285.         AISetWpnt(t_Waypoint00[n_idx], n_idx);
  286.     }
  287.  
  288.     AIConnectWpnts(0, 1);
  289.     AIConnectWpnts(0, 3);
  290.     AIConnectWpnts(1, 2);
  291.     AIConnectWpnts(2, 5);
  292.     AIConnectWpnts(3, 4);
  293.     AIConnectWpnts(3, 6);
  294.     AIConnectWpnts(4, 5);
  295.     AIConnectWpnts(4, 6);
  296.     AIConnectWpnts(5, 7);
  297.     AIConnectWpnts(6, 8);
  298.     AIConnectWpnts(7, 10);
  299.     AIConnectWpnts(8, 9);
  300.     AIConnectWpnts(9, 10);
  301.  
  302.     return;
  303.  
  304. # ========================================================================================
  305. DeactivateWaypoints:
  306.     if (!b_WpntsActive)
  307.     {
  308.         return;
  309.     }
  310.  
  311.     b_WpntsActive = 0;
  312.     AIClearInstinctWpntMode(t_Jag);
  313.     StopThing(t_Jag);
  314.  
  315.     return;
  316.  
  317. # ========================================================================================
  318. RankFor9:
  319.     n_FleeToWaypoint = 9;
  320.  
  321.     AISetWpntRank(0, 0);
  322.     AISetWpntRank(1, 0);
  323.     AISetWpntRank(2, 0);
  324.  
  325.     AISetWpntRank(3, 5);
  326.     AISetWpntRank(4, 5);
  327.     AISetWpntRank(5, 5);
  328.  
  329.     AISetWpntRank(6, 10);
  330.     AISetWpntRank(7, 10);
  331.  
  332.     AISetWpntRank(8, 15);
  333.     AISetWpntRank(10, 15);
  334.  
  335.     AISetWpntRank(9, 20);
  336.  
  337.  
  338.     return;
  339.  
  340.  
  341. # ========================================================================================
  342. RankFor1:
  343.     n_FleeToWaypoint = 1;
  344.  
  345.     AISetWpntRank(1, 20);
  346.  
  347.     AISetWpntRank(0, 15);
  348.     AISetWpntRank(2, 15);
  349.  
  350.     AISetWpntRank(3, 10);
  351.     AISetWpntRank(4, 10);
  352.     AISetWpntRank(5, 10);
  353.  
  354.     AISetWpntRank(6, 5);
  355.     AISetWpntRank(7, 5);
  356.  
  357.     AISetWpntRank(8, 0);
  358.     AISetWpntRank(9, 0);
  359.     AISetWpntRank(10, 0);
  360.  
  361.     return;
  362.  
  363.  
  364. # ========================================================================================
  365. RankFor10:
  366.     n_FleeToWaypoint = 10;
  367.  
  368.     AISetWpntRank(0, 0);
  369.  
  370.     AISetWpntRank(1, 5);
  371.     AISetWpntRank(3, 5);
  372.  
  373.     AISetWpntRank(6, 10);
  374.     AISetWpntRank(4, 10);
  375.     AISetWpntRank(2, 10);
  376.  
  377.     AISetWpntRank(8, 15);
  378.     AISetWpntRank(5, 15);
  379.  
  380.     AISetWpntRank(9, 20);
  381.     AISetWpntRank(7, 20);
  382.  
  383.     AISetWpntRank(10, 25);
  384.  
  385.     return;
  386.  
  387. # ========================================================================================
  388. RankFor0:
  389.     n_FleeToWaypoint = 0;
  390.  
  391.     AISetWpntRank(0, 25);
  392.  
  393.     AISetWpntRank(1, 20);
  394.     AISetWpntRank(3, 20);
  395.  
  396.     AISetWpntRank(6, 15);
  397.     AISetWpntRank(4, 15);
  398.     AISetWpntRank(2, 15);
  399.  
  400.     AISetWpntRank(8, 10);
  401.     AISetWpntRank(5, 10);
  402.  
  403.     AISetWpntRank(9, 5);
  404.     AISetWpntRank(7, 5);
  405.  
  406.     AISetWpntRank(10, 0);
  407.  
  408.     return;
  409.  
  410. # ========================================================================================
  411. RankFor2:
  412.     n_FleeToWaypoint = 2;
  413.  
  414.     AISetWpntRank(2, 25);
  415.  
  416.     AISetWpntRank(1, 20);
  417.     AISetWpntRank(5, 20);
  418.  
  419.     AISetWpntRank(0, 15);
  420.     AISetWpntRank(4, 15);
  421.     AISetWpntRank(7, 15);
  422.  
  423.     AISetWpntRank(3, 10);
  424.     AISetWpntRank(10, 10);
  425.  
  426.     AISetWpntRank(6, 5);
  427.     AISetWpntRank(9, 5);
  428.  
  429.     AISetWpntRank(8, 0);
  430.  
  431.     return;
  432.  
  433. # ========================================================================================
  434. RankFor8:
  435.     n_FleeToWaypoint = 8;
  436.  
  437.     AISetWpntRank(2, 0);
  438.  
  439.     AISetWpntRank(1, 5);
  440.     AISetWpntRank(5, 5);
  441.  
  442.     AISetWpntRank(0, 10);
  443.     AISetWpntRank(4, 10);
  444.     AISetWpntRank(7, 10);
  445.  
  446.     AISetWpntRank(3, 15);
  447.     AISetWpntRank(10, 15);
  448.  
  449.     AISetWpntRank(6, 20);
  450.     AISetWpntRank(9, 20);
  451.  
  452.     AISetWpntRank(8, 25);
  453.  
  454.     return;
  455.  
  456. # ========================================================================================
  457. ResetWaypointRanks:    
  458.     for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
  459.     {
  460.         AISetWpntRank(n_idx, 0);
  461.     }
  462.  
  463.     return;
  464.  
  465. end
  466.  
  467.